package com.lhj.library.infra.basic.service.impl;

import com.lhj.library.infra.basic.entity.User;
import com.lhj.library.infra.basic.mapper.UserDao;
import com.lhj.library.infra.basic.service.UserService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * (User)表服务实现类
 *
 * @author makejava
 * @since 2023-11-27 23:43:37
 */
@Service("userService")
public class UserServiceImpl implements UserService {
    @Resource
    private UserDao userDao;

    /**
     * 通过ID查询单条数据
     *
     * @return 实例对象
     */
    @Override
    public User queryByCondition(User user) {
        return this.userDao.queryByCondition(user);
    }


    /**
     * 新增数据
     *
     * @param user 实例对象
     * @return 实例对象
     */
    @Override
    public Integer insert(User user) {
        return this.userDao.insert(user);
    }

    /**
     * 修改数据
     *
     * @param user 实例对象
     * @return 实例对象
     */
    @Override
    public Integer update(User user) {
        return this.userDao.update(user);
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.userDao.deleteById(id) > 0;
    }

    @Override
    public int count(User user) {
        return this.userDao.count(user);
    }

    @Override
    public List<User> selectUserPage(User user, int start, Integer pageSize) {
        return this.userDao.selectUserPage(user,start,pageSize);
    }
}
